package com.mzy.interview

import java.util.*
import kotlin.math.min

class MinStack() {
    val stack:LinkedList<Int>
    val minStack:LinkedList<Int>
    init {
        stack = LinkedList()
        minStack = LinkedList()
    }
    fun push(`val`: Int) {
        stack.push(`val`)
        if(minStack.isEmpty() || minStack.peek() >= `val`){
            minStack.push(`val`)
        }
    }
    // -2   -2
    // 0    -3
    // -3
    fun pop() {
        if(!stack.isEmpty() && stack.pop() == minStack.peek()) {
            minStack.pop()
        }
    }

    fun top(): Int {
        return stack.peek();
    }

    fun getMin(): Int {
        return minStack.peek();
    }

}

fun main() {
    val stack = MinStack()
    var linkedList = LinkedList<Int>()
}